package com.wangzefeng.shop.controller;

import com.wangzefeng.shop.pojo.CommonResult;
import com.wangzefeng.shop.pojo.MenuVo;
import com.wangzefeng.shop.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: wangzefeng
 * @Date: 2021/3/22 15:12
 * @Description:
 */
@RestController
@RequestMapping("/menus")
public class MenuController {

    @Autowired
    SysMenuService sysMenuService;

    @GetMapping("/tree/{roleId}")
    public CommonResult tree(@PathVariable("roleId") int roleId){
        List<MenuVo> menuTree = sysMenuService.getMenuTreeByRoleId(roleId);
        return CommonResult.getSuccessResult(menuTree);
    }
}
